<% add_decidim_page_title(t(".title")) %>
<div class="card">
  <div class="item_show__header item_show__header--with-action-options">
    <h1 class="item_show__header-title">
      <div>
        <% if parent_result %>
          <%= "#{translated_attribute(parent_result.title)} > " %>
        <% end %>
        <%= t(".title") %>
        <span data-selected-count class="component-counter" title="<%= t(".selected") %>"></span>
      </div>

      <div class="flex items-center gap-x-4">
        <%= render partial: "decidim/accountability/admin/results/bulk_actions/dropdown" %>
        <%= export_dropdowns(query) %>
        <%= import_dropdown do %>
          <% if allowed_to?(:create, :result) && parent_result.nil? %>
            <li class="dropdown__item">
              <%= link_to new_import_component_path, class: "dropdown__button" do %>
                <%= t("actions.import", scope: "decidim.accountability", name: t("models.result.name", scope: "decidim.accountability.admin")) %>
              <% end %>
            </li>
          <% end %>
          <% if allowed_to? :create, :result %>
            <li class="dropdown__item">
              <%= link_to import_results_path, class: "dropdown__button" do %>
                <%= t("actions.import_csv", scope: "decidim.accountability") %>
              <% end %>
            </li>
          <% end %>
        <% end %>
        <%= render partial: "decidim/accountability/admin/shared/subnav" unless parent_result %>
        <%= link_to t("actions.new_result", scope: "decidim.accountability"), new_result_path(parent_id: parent_result), class: "button button__sm button__secondary" if allowed_to? :create, :result %>
        <%= render partial: "decidim/admin/components/resource_action" %>
      </div>
    </h1>

    <%= render partial: "decidim/accountability/admin/results/bulk_actions/taxonomies_form" %>
    <%= render partial: "decidim/accountability/admin/results/bulk_actions/status_form" %>
    <%= render partial: "decidim/accountability/admin/results/bulk_actions/dates_form" %>
  </div>

  <%= admin_filter_selector(:results) %>
  <div class="table-stacked">
    <table class="table-list">
      <%= render partial: "decidim/accountability/admin/results/results-thead", locals: { query: } %>
      <tbody>
        <%= render partial: "decidim/accountability/admin/results/result-tr",
                   collection: results,
                   as: :result,
                   locals: { view: :index } %>
      </tbody>
    </table>
  </div>
  <% if allowed_to? :manage_trash, :result, participatory_space: current_participatory_space %>
    <div class="card mt-4">
      <%= link_to manage_trash_results_path(parent_id: params[:parent_id].presence), class: "flex items-center  text-secondary" do %>
        <%= icon "delete-bin-2-line", class: "mr-2 fill-current text-secondary", role: "img" %>
        <%= t("actions.view_deleted_results", scope: "decidim.accountability") %>
        <span class="ml-2">
          <%= icon_with_tooltip("information-line", t("actions.deleted_results_info", scope: "decidim.accountability")) %>
        </span>
      <% end %>
    </div>
  <% end %>
</div>
<%= decidim_paginate results %>

<%= append_javascript_pack_tag "decidim_accountability_admin_index" %>
